<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>我的信息</title>
    <style>
          body{
            width: 100%;
            height: 100%;
            background-image:url(./txt/image/背景1.jpg);
            background-repeat: no-repeat;
            background-size:100% 100vh;
        }
        *{
            list-style: none;
            margin: 0;
            padding:0;
            box-sizing: border-box;
            text-decoration: none;
        }
        .box{
            width: 500px;
            height: 350px;
            margin:200px auto;
            border: 1px solid #999;
            border-radius: 10px;
            backdrop-filter: blur(8px);
            box-shadow: 10px 10px 20px rgba(0,0,0,0.2);
            border-top: 1px solid rgba(255,255,255,0.8);
            border-left: 1px solid rgba(255,255,255,0.8);
        }
      .box h4{
        margin-top: 10px;
        width: 100%;
        height: 30px;
        text-align: center;
      }
li{
    width: 100%;
    height: 30px;
    line-height: 30px;
    margin-top: 10px;

 padding-left: 150px;
    display: flex;
    justify-content:flex-start;
}
h5{
    width: 200px;
    text-align: center;
}
p{
    margin-top: 20px;
    width: 100%;
    height: 30px;
    text-align: center;
}
p button{
    width: 80px;
    height: 30px;
    line-height: 30px;

}
    </style>
</head>
<script src="./txt/js/axios.js"></script>
<body>
    <div class="box">
        <h4>我的信息</h4>
        <hr>
        <ul>
            <li><strong>用户名:&nbsp;</strong><h5 id="username"></h5></li>
            <li><strong>昵称:&nbsp;&nbsp;&nbsp;&nbsp;</strong><h5 id="othername"></h5></li>
            <li><strong>性别:&nbsp;&nbsp;&nbsp;&nbsp;</strong><h5 id = 'sex'></h5></li>
            <li><strong>电子邮件:</strong><h5 id="email"></h5></li>
            <li><strong>电话:&nbsp;&nbsp;&nbsp;&nbsp;</strong><h5 id='phone'></h5 ></li>
            <li><strong>地址:&nbsp;&nbsp;&nbsp;&nbsp;</strong><h5 id="address"></h5 ></li>
        </ul>
        <p><button id="btn_return">返回</button></p>
    </div>
    <script>
        const usersname = document.getElementById('username')
        const othername = document.getElementById('othername')
        const sex = document.getElementById('sex')
        const email = document.getElementById('email')
        const phone = document.getElementById('phone')
        const  address= document.getElementById('address')   
        const btn_return  = document.getElementById('btn_return')
       var message = JSON.parse(localStorage.getItem('user'))
       if(message.login_user === '客户'){
         var xi = axios({
            url:'http://127.0.0.1:8080/searchuser',
            method:'post',
            data:{
               usermessage:message.login_message
            }
        })
         xi.then((res)=>{
        usersname.innerHTML = res.data[0].username
        othername.innerHTML = res.data[0].nickname
        sex.innerHTML = res.data[0].sex
        email.innerHTML = res.data[0].email
        phone.innerHTML = res.data[0].phone
        address.innerHTML = res.data[0].address
        })
       }
       if(message.login_user === '客服'){
        var xi = axios({
            url:'http://127.0.0.1:8080/searchservice',
            method:'post',
            data:{
               usermessage:message.login_message
            }
        })
        xi.then((res)=>{
        usersname.innerHTML = res.data[0].username
        othername.innerHTML = res.data[0].nickname
        sex.innerHTML = res.data[0].sex
        email.innerHTML = res.data[0].email
        phone.innerHTML = res.data[0].phone
        address.innerHTML = res.data[0].address
        })
       }
          btn_return.addEventListener('click',function(){
            window.location.href = './main.html'
          })
    </script>
</body>
</html>